<%@page contentType="text/html" pageEncoding="windows-1252"%>
<%@page import="java.sql.SQLException"%>
<%@page import="startup.model.user.Administrator"%>
<%
	try
	{
		// creo un array di cookie assegnandoli quelli del client
		Cookie[] cookies = request.getCookies();

		// definisco e creo i cookie che mi servono nella pagina
		Cookie userIdCookie = new Cookie( "userId", "0" );
		Cookie studentFundCookie = new Cookie( "studentFund", "0" );
		Cookie studentFNameCookie = new Cookie( "first_name", ".." );
		Cookie studentLNameCookie = new Cookie( "last_name", ".." );

		Administrator administrator = ( Administrator )session.getAttribute( "currentSessionUser" );
		administrator.nameOfAdmin();

		//ciclo l'array e per assegnare ai cookie il valore che voglio facendo un check sulla chiave
		for( int i = 0; i < cookies.length; i++ )
		{
			if( cookies[i].getName().equals( "userId" ) )
			{
				userIdCookie.setValue( cookies[ i].getValue() );
			}
			else if( cookies[i].getName().equals( "studentFund" ) )
			{
				studentFundCookie.setValue( cookies[ i].getValue() );
			}
			else if( cookies[i].getName().equals( "first_name" ) )
			{
				studentFNameCookie.setValue( cookies[ i].getValue() );
			}
			else if( cookies[i].getName().equals( "last_name" ) )
			{
				studentLNameCookie.setValue( cookies[ i].getValue() );
			}
		}
%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="windows-1252">
		<title>Administrator</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="">
		<!-- Le styles -->
		<link href="styles/bootstrap.css" rel="stylesheet">
		<style type="text/css">
			body {
				padding-top: 60px;
				padding-bottom: 40px;
			}
			.sidebar-nav {
				padding: 9px 0;
			}
		</style>
	</head>
	<body>
        <!--Barra Superiore-->
        <div class="navbar navbar-fixed-top">
			<div class="navbar-inner">
				<div class="container-fluid">
					<a class="brand" href="#">Administrator : <%= administrator.getSurname() %> <%= administrator.getName() %></a>
					<div class="nav pull-right">
						<ul class="nav">
							<li>
								<form action="Logout" method="post">
									<button class="btn btn-primary btn-small">Sign out</button>
								</form>
							</li>
						</ul>
					</div>
				</div>
			</div>
        </div>
		<!--CONTENUTO LISTE -->
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span3" style="position: fixed;">
					<div class="well sidebar-nav">
						<ul class="nav nav-list"> 
							<li><a href="javascript:history.back()"><i class="icon-arrow-left"></i> Back</a></li>
							<li class="nav-header">Location</li>
							<li><a href="administratorHome.jsp"><i class="icon-home"></i> Home</a></li>
							<li><a href="javascript:history.back()"> &nbsp; &bull; <i class="icon-list-alt"></i> Students with similar name</a></li>
							<li class="active"><a href="#"> &nbsp; &bull; <i class="icon-white icon-pencil"></i> Modify student's fund</a></li>
							<li class="nav-header">Functions</li>
							<li><a href="administratorHome.jsp"><i class="icon-search"></i> New Search</a></li>
							<li><a href="administratorFAQ.jsp"><i class="icon-info-sign"></i> F.A.Q.</a></li>
						</ul>
					</div><!--/.well -->
				</div><!--/span-->
				<div class="span9" style="margin-left: 26%;">
					<div class="hero-unit">
						<h1> Modification of the fund <br /><br /></h1>
						<h2><%= studentFNameCookie.getValue() %> <%= studentLNameCookie.getValue() %> </h2>
						<br />
						<h3>
							Student's id  :<%= userIdCookie.getValue() %>  <br />
							Student's fund:<%= studentFundCookie.getValue() %>
						</h3>
						<h6>Decimal numbers are not allowed (e.g: 13.90 or 13,90 will be refused)</h6><br />
						<form action="AdministratorUpdateFund" method="post">
							<input name="studentId" type="hidden" value="<%= userIdCookie.getValue() %>"/>
							<input name="newFund" type="text" maxlength="10" /><br />
							<button class="btn btn-primary btn-large">Modify Fund</button>
						</form>
					</div>
					<!--CONTENUTO LISTE -->
					<div class="row-fluid">
					</div>
				</div>
			</div>
        </div><!--/.fluid-container-->
        <div class="navbarCC navbar-fixed-bottom">
            <div class="navbarCC-inner">
                <div class="container-fluid">				
                    <a class="brand" href="#">&copy; 2012 Startup</a>					
                </div>
            </div>
        </div>
		<!-- Il javascript -->
		<script src="js/jquery.js"></script>
		<script src="js/bootstrap.js"></script>
	</body>
</html>
<%
	}
	catch( SQLException sqlException )
	{
		sqlException = new SQLException( "The database is currently busy.<br />" +
										 "If the problem persists, please report it to the administration." );
		request.setAttribute( "exception", sqlException );
		request.getRequestDispatcher( "errorPage.jsp" ).forward( request, response );
	}
	catch( RuntimeException runtimeException )
	{
		if( runtimeException.getClass().equals( NullPointerException.class ) )
		{
			runtimeException = new NullPointerException( "The session has timed out:<br />" + "" +
														 "try reloading page.<br />" +
														 "If the problem persists, please report it to the administration." );
		}
		request.setAttribute( "exception", runtimeException );
		request.getRequestDispatcher( "errorPage.jsp" ).forward( request, response );
	}
%>